<template>
	<view class="container">
		<image class="v-bg" :src="datas.Url" mode="scaleToFill"></image>
		<uni-popup ref="message" type="message" class="pop-msg">
			<uni-popup-message :type="msgType" :message="messageText" :duration="duration"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
	import {
		dateUtils,
		authTokenUtil,
		validLoginToken
	} from "../../common/util.js"
export default {
	data() {
		return {
			messageText: '',
			msgType: 'success',
			duration: 2000,

			datas: {
				Url: ''
			}
		};
	},
	methods: {
		getServerPath: function (url) {
			let _this = this;
			console.log(`${_this.sysInfo.ImageBasePath}${url}`);
			return `${_this.sysInfo.ImageBasePath}${url}`;
		},
		getInviteCode: function () {
			console.log('getInviteCode');
			let _this = this;
			//正式代码
			var authToken = authTokenUtil();

			uni.request({
				url: _this.sysInfo.BasePath + 'Sys/GetInviteImage',
				method: 'POST',
				data: null,
				header: {
					'content-type': 'application/json',
					Authorization: `${authToken}`
				},
				success: (res) => {
					if (res && res.data && res.data.Succeeded === true) {
						console.log(res);
						_this.datas.Url = _this.getServerPath(res.data.Data);
					} else {
						_this.sysUtils.tip({
							sender: _this,

							title: '加载邀请海报信息失败！',
							icon: 'error'
						});
					}
				},
				fail: () => {
					_this.sysUtils.tip({
						sender: _this,
						title: '加载邀请海报信息失败！',
						icon: 'error'
					});
				},
				complete: () => {}
			});
		},
		init: function () {
			let _this = this;
			console.log('init');
			_this.getInviteCode();
		}
	},
	onShow() {
		let _this = this;
		// _this.init();
	},
	created() {
		let _this = this;
		validLoginToken(null, () => {
			uni.reLaunch({
				url: "/pages/account/login"
			})
		})
		_this.init();
	}
};
</script>

<style>
.container {
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: stretch;
	position: fixed;
	width: 100%;
	height: 100%;
}

.v-bg {
	height: 100%;
	width: 100%;
}
</style>
